package com.koron.css2.baseConfig.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.baseConfig.bean.MeterStatusBean;
import com.koron.css2.baseConfig.mapper.MeterStatusMapper;
import com.koron.css2.baseConfig.queryBean.MeterStatusQueryBean;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;
/**
 * 抄表状态-编辑初始化
 * @author 李攀
 *
 */
public class MeterStatusQuery implements ServerInterface {
	
private static Logger logger = LogManager.getLogger(MeterStatusQuery.class);
	
	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {

		@SuppressWarnings("rawtypes")
		MessageBean<MeterStatusBean> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", MeterStatusBean.class);

		try { 
			MeterStatusQueryBean bean = JsonUtils.objectToPojo(req.getData(), MeterStatusQueryBean.class);
			MeterStatusMapper mapper = factory.getMapper(MeterStatusMapper.class);
			MeterStatusBean MeterStatusbean = mapper.selectMeterStatusById(bean.getStatusId());
			info.setData( MeterStatusbean);
		} catch (Exception e) {
			info.setCode(Constant.MESSAGE_INT_FAIL);
			info.setDescription(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return info;
	}
}
